package model;

import java.util.Random;

/**
 * 房价数据
 *
 * @author wangkai
 * @since 2024/8/27.
 */
public class HouseData {
    static Random random = new Random();
    /**
     * 面积
     */
    private double s;
    /**
     * 价格
     */
    private double price;

    public HouseData(double s) {
        this.s = s;
        this.price = getRealPrice(s);
    }

    public HouseData(double s, double price) {
        this.s = s;
        this.price = price;
    }

    /**
     * 真实房价
     *
     * @param s 房子面积
     *
     * @return 房价
     */
    public static double getRealPrice(double s) {
        // 公式： 面积 * 100 + 真实波动
        // random.nextInt(30) 噪声，模拟真实的波动
        return s * 100 + random.nextInt(30);
    }

    public double getS() {
        return s;
    }

    public double getPrice() {
        return price;
    }
}